{template 'common/header-gw'}
<ol class="breadcrumb">
	<li><a href="./?refresh"><i class="fa fa-home"></i></a></li>
	<li><a href="{url 'system/welcome'}">用户管理</a></li>
	<li class="active">{if $_GPC['status'] == -1}审核用户{elseif empty($_GPC['status'])}用户列表{/if}</li>
</ol>
<script type="text/javascript">
	var u ={};
	require(['jquery', 'util'], function($, s){
		u.deny = function(uid, status){
			var uid = parseInt(uid);
			if(isNaN(uid)) {
				return;
			}
			if(!confirm('确认要禁用/解禁此用户吗? ')) {
				return;
			}
			$.post('{php echo url('user/permission');}', {'do': 'deny', uid: uid, status: status}, function(dat){
				if(dat == 'success') {
					location.href = location.href;
				} else {
					s.message('操作失败, 请稍后重试. ' + dat);
				}
			});
		};
		u.del = function(uid){
			var uid = parseInt(uid);
			if(isNaN(uid)) {
				return;
			}
			if(!confirm('确认要删除此用户吗? ')) {
				return;
			}
			$.post('{php echo url('user/edit');}', {'do': 'delete', uid: uid}, function(dat){
				if(dat == 'success') {
					location.href = location.href;
				} else {
					s.message('操作失败, 请稍后重试. ' + dat);
				}
			});
		};

	});
</script>
<ul class="nav nav-tabs">
	<li {if empty($_GPC['status'])}class="active"{/if}><a href="{php echo url('user/display');}">用户列表</a></li>
	{if !empty($settings['verify'])}<li {if $_GPC['status'] == -1}class="active"{/if}><a href="{php echo url('user/display', array('status' => -1));}">审核用户</a></li>{/if}
	<li><a href="{php echo url('user/create');}">添加用户</a></li>
</ul>

<div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="" method="get" class="form-horizontal" role="form">
		<input type="hidden" name="c" value="user">
		<input type="hidden" name="a" value="display">
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
				<div class="col-sm-8 col-lg-9">
					<select name="status" class="form-control">
						<option value="">全部</option>
						<option value="0" {if $_GPC['status'] == '0'} selected{/if}>启用</option>
						<option value="-1" {if $_GPC['status'] == '-1'} selected{/if}>禁用</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">用户名</label>
				<div class="col-sm-8 col-lg-9">
					<input class="form-control" name="username" id="" type="text" value="{$_GPC['username']}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">用户组</label>
				<div class="col-sm-8 col-lg-9">
					<select name="group" class="form-control">
						<option value="">全部</option>
						{loop $usergroups $group}
						<option {if $_GPC['group'] == $group['id']} selected{/if} value="{$group['id']}">{$group['name']}</option>
						{/loop}
					</select>
				</div>
				<div class="pull-right col-xs-12 col-sm-2 col-lg-2">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
			<div class="form-group">
			</div>
		</form>
	</div>
</div>
<div class="rule panel panel-default">
	<div class="table-responsive panel-body">
	<table class="table table-hover">
		<thead class="navbar-inner">
			<tr>
				<th style="width:120px;">用户名</th>
				<th style="width:150px;">身份</th>
				<th style="width:150px;">状态</th>
				<th style="width:180px;">注册时间</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			{loop $members $m}
			<tr>
				<td>{if !$m['founder']}<a href="{php echo url('user/edit', array('uid' => $m['uid']))}">{$m['username']}</a>{else}{$m['username']}{/if}</td>
				<td>{php echo $m['founder'] ? '<span class="label label-success">管理员</span>' : (isset($usergroups[$m['groupid']]) ? '<span class="label label-info">'.$usergroups[$m['groupid']]['name'].'</span>' : '<span class="label label-error">未分配</span>');}</td>
				<td>{php echo $m['status'] == '-1' ? '<span class="label label-danger">被禁止</span>' : '';}</td>
				<td>{php echo date('Y-m-d H:i:s', $m['joindate'])}</td>
				<td>
					{if !$m['founder']}
					<div><a href="{php echo url('user/edit', array('uid' => $m['uid']))}">编辑</a>&nbsp;&nbsp;<a href="{php echo url('user/permission', array('uid' => $m['uid']))}">查看操作权限</a>&nbsp;&nbsp;<a href="javascript:;" onclick="u.deny('{$m['uid']}', '{php echo $m['status'] == '-1' ? '0' : '-1';}');">{php echo $m['status'] == '-1' ? '启用' : '禁止';}用户</a>&nbsp;&nbsp;<a href="javascript:;" onclick="u.del('{$m['uid']}');">删除用户</a></div>
					{/if}
				</td>
			</tr>
			{/loop}
		</tbody>
	</table>
	</div>
</div>
{$pager}
{template 'common/footer-gw'}
